package emulator.support;

import emulator.hardware.HwByte;
import emulator.util.MemoryPtr;

public class ZeroPageOperandEval implements OperandEval {

	MemoryPtr instruction;
	
	public ZeroPageOperandEval(MemoryPtr ptr) {
		instruction = ptr;
	}

	@Override
	public String getDetails(CpuState cpu_state) {
		int old_address = instruction.getAddress();
		int operand = instruction.getByteOp();
		instruction.setAddress(operand);
		String result = "($" + new HwByte(operand) + ") -> $" + new HwByte(instruction.getByteOp());
		instruction.setAddress(old_address);
		return result;
	}

	@Override
	public boolean isAddress() {
		return true;
	}

	@Override
	public int getAddress(CpuState cpu_state) {
		return instruction.getByteOp();
	}

	@Override
	public boolean isIndirect() {
		return false;
	}
}
